$(function(){
    obj.init();
});

var obj = new JsFun();
function JsFun(){
    'use strict';
    return {
        dataGrid: null,
        schoolId: null,
        init: function () {
            window.top.swal.resetDefaults();
            this.schoolId = xhTool.getQuery('iSchoolId');
            console.log(this.schoolId);
            this.dataGrid = new xhDataGrid($('#list'), 'School/getProjectData?schoolId='+this.schoolId);
            this.dataGrid.parseToolbar().init().activeButton(['bt_list_del']);
            this.listener();
            this.funObj().bindDataGridEvent();
        },
        listener: function () {
            var $this = this;
            $("#bt_list_add").click(function () {
                window.top.xhTop.showModal({
                    title:'项目历史-添加',
                    content: '<iframe src="'+baseUrl+'school/projectForm?schoolId='+$this.schoolId+'"  style="width: 100%;;border-style: none;padding: 0px;height:500px;"  scrolling="yes"  ></iframe>',
                    width:675,
                    backClose:false,
                    button: '保存'
                });
            });
            $("#bt_list_del").click(function () {
                if(xhExtra.buttonDisabled($(this))){
                    return false;
                }
                var iIds = $this.dataGrid.getSelectValues('iId');
                console.log(iIds);
                xhExtra.askChangeStatus('School/delProject', {ids: iIds}, $this.dataGrid);
            });
            $('#bt_list_check').click(function () {
                var iIds = $this.dataGrid.getSelectValues('iId');
                xhExtra.askChangeStatus('School/checkProject', {ids: iIds}, $this.dataGrid, '确定要这么做吗？');
            });
        },
        funObj: function(){
            var $this = this;
            return {
                bindDataGridEvent: function () {
                    $this.dataGrid.onDblClickRow = function (rowIndex, rowData) {
                        console.log(rowData.iId);
                        window.top.xhTop.showModal({
                            title:'项目历史-更新',
                            content: '<iframe src="'+baseUrl+'school/projectForm?schoolId='+$this.schoolId+'&id='+rowData.iId+'"  style="width: 100%;;border-style: none;padding: 0px;height:500px;"  scrolling="yes"  ></iframe>',
                            width:675,
                            backClose:false,
                            button: '保存'
                        });
                    };
                },
            }
        }
    }
}

